
function Feeds(){
	
	var self = Ti.UI.createWindow({
		layout:"vertical",
		backgroundColor:'#ffffff'
	});
	
	
	var mainView = Ti.UI.createScrollView({
		layout:'vertical'
	});
	

	var data = [];

	var xhr = Ti.Network.createHTTPClient();
//xhr.open("GET","http://v2.0.news.tmg.s3.amazonaws.com/feeds/news.xml");
//http://thethao.vnexpress.net/rss/tin-moi-nhat.rss
//xhr.open("GET","http://www.aftonbladet.se/kultur/rss.xml");
	xhr.open("GET","http://thethao.vnexpress.net/rss/tin-moi-nhat.rss");
	xhr.onload = function()
	{
		var doc = this.responseXML.documentElement;
		var items = doc.getElementsByTagName("item");
		var x = 0;
		var doctitle = doc.evaluate("//channel/title/text()").item(0).nodeValue;
		for (var c=0;c<items.length;c++)
		{
  			var item = items.item(c);​​​​​​
  			var strDesc = item.getElementsByTagName("description").item(0).text;	
			var src = strDesc.match(/src="([^\"]*)"/gim);
		   	var imgPath = src[0].replace(/src=|"/gim, "");
		   	var date = item.getElementsByTagName("pubDate").item(0).text;
		   	var title = item.getElementsByTagName("title").item(0).text;
		   	var description = item.getElementsByTagName("description").item(0).text;
		   	var row = Ti.UI.createTableViewRow({height:80});
	
		    var label = Ti.UI.createLabel({
		      text:title,
		      left:25,
		      top:20,
		      bottom:5,
		      right:5
		    });
		    row.add(label);


		    var label1 = Ti.UI.createLabel({
		      text:date,
		      left:25,
		      top:-30,
		      bottom:5,
		      right:5
		    });
   		 	row.add(label1);        

		    var img = Ti.UI.createImageView({
		      url:imgPath,
		      left:5,
		      height:60,
		      width:60
		    });
		    row.add(img);
		    data[x++] = row;
		    row.url = item.getElementsByTagName("link").item(0).text;

		}
		var tableview = Titanium.UI.createTableView({data:data});
		mainView.add(tableview);
		
	};
	xhr.send();
	/////////////


	self.add(mainView);
	return self;
}

module.exports = Feeds;